home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: Need Help compiling M
- X-Nntp-Posting-Host: golden.ripco.com
- Message-ID: <DL62Bz.4uJ@rci.ripco.com>
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Sun, 14 Jan 1996 10:26:22 GMT
- X-Ident-Sender: mambuhl
-
- "Thomas J. Hruska" <71524.2020@compuserve.com>
- in <4d8aph$9it@dub-news-svc-5.compuserve.com> asks:
-
- >Does anyone know how in the world to compile Microsoft C code using a
- >Borland C/C++ compiler?!?!? I couldn't make heads or tails of what the
- >stupid manual said...
-
- 0) It is commonly held that compiler-specific problems do not belong in
- comp.lang.c, but usually in a system-specific newsgroup (e.g.
- comp.os.msdos.programmer). While I usually agree with this view,
- porting questions have two characteristics that make me provide an
- answer for this question. First, porting is something that C
- programmers must often do, and usually the only people you can ask are
- other C programmers. This is obviously more true when the port is
- cross-platform, rather than cross-compiler on the same platform as here.
- Second, many of the problems which are run into for a particular port
- have some generalizability. I hope some of the following is useful.
-
- 1) Most of the code should be ANSI C, and that part should port without
- problems. The code which is not ANSI C should -- as far as possible --
- be converted to standard C before you do anything else.
-
- 2) Historically, there have been a number of implementation-dependent
- library functions with different names (and parameter lists and return
- values) in Microsoft and Borland implementations. Borland has tried to
- provide implementations of the MS form. For example, you will find
-
- unsigned _dos_findnext(struct find_t *ffblk); /* MS call */
- int findnext(struct ffblk *ffblk); /* Borland call */
-
- The Borland implementation has long provided both forms, so no problems
- arise with the MS->Borland port. None the less, the parts of your code
- using such implementation-specific code should be separated as much as
- possible into implementation-specific files, and every effort should be
- made to make it easily changed if you should want to port the code to
- some other compiler (say gcc) or environment (say a unix variant, Linux
- or FreeBSD for example) or machine (say DEC Alpha, Sun, etc.).
-
- The rule is: if several functions may provide the functionality you
- need, prefer them in this order (see the library docs):
- a) The ANSI C function (Your implementation should provide this).
- b) The UNIX (or POSIX) function that your implementation provides.
- c) The function which your implementation (Borland) and the
- source implementation (MS) both provide.
- d) The your-implementation(Borland)-only function
-
- 3) Unless you have become very familiar with make, do not bother trying
- to learn how to convert MS makefiles to Borland makefiles. They both
- differ substantially from more common versions of make. Do as much as
- possible with the IDE. You will want to become comfortable with make in
- the long run, of course.
-
- 4) Rather than set the environment variables LIB and INCLUDE, change the
- default paths in the IDE. If you stick to the IDE, you needn't worry
- about differences in the command-line switches either. You will, of
- course, ultimately want to become intimate with the command-line
- version.
-
- 5) If your code uses the non-standard <dos.h> header,
- #define __MSC /* before #include <dos.h> */
- so the DOSERROR structure will match MS's.
-
- For the following non-standard headers, either name should work:
- <dir.h> | <dirent.h>
- <mem.h> | <memory.h> /* BUT: consider <string.h> */
-
- Replace any #includes of either <alloc.h> or <malloc.h> with the
- standard <stdlib.h>. If this makes a change in the code necessary
- (unlikely), make the change.
-
- 6) If the code contains these keywords, you will have problems. These
- are non-standard and the code should be rewritten (if possible) to
- exclude them:
-
- MS-keyword: possible BCC/TCC-cure:
- _based #define _based
- _self #define _self
- _segname #define _segname
- _segment #define _segment _seg
- _emit #define _emit(x) __emit__(x)
- _fortran #define _fortran _pascal
-
- 7) You may have problems with floating point or structure return values.
- If so, call Borland Technical Support.
-
- 8) Do _not_ use bitfields or depend on wordsize or rely on alignment of
- members in structs or unions. Do _not_ use the words "far", "near",
- "pascal", "interrupt" and similar things in the body of your code. Use
- macros like
- #define FAR far
- which you can later change (in a rational environement) to
- #define FAR
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-